Skip to content

fix(pdf): Improve printable event form#316

Merged
ToivoMattilaHelsinki merged 11 commits into
mainfrom
PS-275-printable-event-form
Jun 12, 2026
Merged

fix(pdf): Improve printable event form#316
ToivoMattilaHelsinki merged 11 commits into
mainfrom
PS-275-printable-event-form

Conversation

@ToivoMattilaHelsinki

@ToivoMattilaHelsinki ToivoMattilaHelsinki commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Description

Refs: PS-275

This PR improves the printable PDF version of the event form.

It cleans up the print layout, aligns rows more consistently, and removes screen-only helper text that is not useful in the contractor-facing PDF. It also adds print-only rendering for date and time values so the PDF shows the actual event schedule even when the interactive fields are hidden.

What changed

Added print-only values for event start/end date and time in DateRange
Wrapped DateRange in a print-visible container so those values render in the PDF
Tightened print CSS so form rows align consistently across responsive column layouts
Hid non-essential helper copy and optional content from the printed form
Added regression coverage for the print-specific date/time rendering

Notes

This is limited to the printable PDF path.
Normal form behavior and submission flow are unchanged.

New PDF

Attached is an image of what the PDF looks now

image

Summary by CodeRabbit

  • New Features

    • Improved print/PDF layout for event forms: tighter spacing, normalized grid, consistent typography, and print-only spacing fixes
    • Print-only summaries for start/end date and time and a compact delivery location line
    • Printable behavior refined for section subtitles and submit area so on-screen notes are skipped from print; printable notes distinguish empty vs. non-empty cases
  • Tests

    • Added unit tests for printable rendering of the event form, date range, and location components

@ToivoMattilaHelsinki ToivoMattilaHelsinki requested a review from a team as a code owner May 27, 2026 10:18
@ToivoMattilaHelsinki ToivoMattilaHelsinki changed the title Ps 275 printable event form fix(pdf): Improve printable event form May 27, 2026
@azure-pipelines

Copy link
Copy Markdown

PUISTOTALKOOT-UI branch is deployed to platta: https://puistotalkoot-pr316-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://puistotalkoot-pr316-ui.dev.hel.ninja 😆🎉🎉🎉

@azure-pipelines

Copy link
Copy Markdown

PUISTOTALKOOT-UI branch is deployed to platta: https://puistotalkoot-pr316-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://puistotalkoot-pr316-ui.dev.hel.ninja 😆🎉🎉🎉

Comment thread src/components/form/partitions/__tests__/Location.test.tsx Fixed
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds print-oriented markup and classes to EventForm, renders compact print summaries in DateRange and Location, introduces tests for printable output, and tightens print.scss to normalize layout and spacing for PDF/print rendering.

Changes

Event form print layout improvements

Layer / File(s) Summary
EventForm print wrapper structure
src/components/form/EventForm.tsx, src/components/form/__tests__/EventForm.test.tsx
StyledForm applies event-form class; section subtitles are wrapped in event-form-print-skip and submit wrapper markup updated. Tests validate printable-note variants.
DateRange print-only rendering
src/components/form/partitions/DateRange.tsx, src/components/form/partitions/__tests__/DateRange.test.tsx
Adds PrintValue and local format helpers, changes handlers to accept non-null Date, wraps content in div.printable.date-range-printable, and inserts print-only start/end date+time summary rows. Tests mock pickers/PrintValue and assert formatted outputs and picker excludeDates.
Location print-only placeholder
src/components/form/partitions/Location.tsx, src/components/form/partitions/__tests__/Location.test.tsx
Renders a print-only paragraph with the localized trash location placeholder above the maintenance location input. Test verifies the print-only label text.
Print stylesheet refinements
src/components/pages/events/print.scss
Shows .print-only elements, positions .printable-area, normalizes Bootstrap grid to single-column print layout, tightens spacing, hides .event-form-print-skip in print, and presents DateRange summaries compactly inline.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I tweak the form for print and cheer,
Subtitles tucked so pages are clear,
Dates and times step neatly in line,
Columns stack gentle, margins align,
PDFs hop out tidy and dear.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: improving the printable event form PDF rendering with better formatting and print-specific content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PS-275-printable-event-form

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Improve browser print and Save as PDF
for the volunteer event form (EventPage).
Hide the three section subtitle blocks in print while
they remain visible on screen.
Tweak padding and form-row font size.

Refs: PS-275
Use Prettier to format DateRange file

Refs: PS-275
@ToivoMattilaHelsinki ToivoMattilaHelsinki force-pushed the PS-275-printable-event-form branch from 6f983ba to 57794f3 Compare June 11, 2026 09:32
Comment thread src/components/form/EventForm.tsx Outdated
Comment thread src/components/form/partitions/DateRange.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/form/EventForm.tsx`:
- Around line 283-289: Guard the use of values.additional_information before
calling .trim() in EventForm.tsx to avoid crashes when it's undefined: change
the conditional that builds the Row className to base the check on a safe string
(e.g., use a nullish default or optional chaining) so you call .trim() on
(values.additional_information ?? '') or use
values.additional_information?.trim() when deciding whether to apply
'event-form-print-note--empty'; update the className logic that references
values.additional_information to use that guarded expression.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa311a2d-8b81-4a69-b5aa-aef1f74805f5

📥 Commits

Reviewing files that changed from the base of the PR and between 6f983ba and 205c227.

📒 Files selected for processing (7)
  • src/components/form/EventForm.tsx
  • src/components/form/__tests__/EventForm.test.tsx
  • src/components/form/partitions/DateRange.tsx
  • src/components/form/partitions/Location.tsx
  • src/components/form/partitions/__tests__/DateRange.test.tsx
  • src/components/form/partitions/__tests__/Location.test.tsx
  • src/components/pages/events/print.scss
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/components/form/tests/EventForm.test.tsx
  • src/components/form/partitions/Location.tsx
  • src/components/form/partitions/tests/Location.test.tsx
  • src/components/form/partitions/tests/DateRange.test.tsx
  • src/components/form/partitions/DateRange.tsx
  • src/components/pages/events/print.scss

Comment thread src/components/form/EventForm.tsx Outdated
@azure-pipelines

Copy link
Copy Markdown

PUISTOTALKOOT-UI branch is deployed to platta: https://puistotalkoot-pr316-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://puistotalkoot-pr316-ui.dev.hel.ninja 😆🎉🎉🎉

Comment on lines +172 to +176
<p className="print-only">
{formatMessage({
id: 'form.event.field.trash_location.placeholder',
})}
</p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The print-only paragraph in the Location component renders a static placeholder label instead of the actual user-entered values.maintenance_location.
Severity: MEDIUM

Suggested Fix

Replace the static placeholder in the print-only paragraph with the actual value from the form state. Use the PrintValue component with values.maintenance_location as the value prop, similar to how other input components handle print rendering. This will ensure the user's input is displayed on the printed form.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/components/form/partitions/Location.tsx#L172-L176

Potential issue: The `Location` component's print-only view, intended for the printable
PDF version of the form, incorrectly displays a static placeholder label. It should
instead render the actual value entered by the user, which is stored in
`values.maintenance_location`. This is inconsistent with how other form fields like
`DateRange` are handled in the same pull request, which correctly display the user's
input in the print view. As a result, any information entered into the maintenance
location field will be missing from the printed document.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/components/form/EventForm.tsx (1)

283-283: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Restore the missing event-form-print-note className with proper guarding.

The Row at line 283 is missing the event-form-print-note className that the tests expect and the print CSS relies on. The past review flagged a crash on values.additional_information.trim() when the field is undefined, but the fix should guard the .trim() call—not remove the className entirely.

Without this className:

  • Tests fail (they assert .event-form-print-note and .event-form-print-note--empty exist)
  • Print layout breaks (CSS at print.scss:170-180 expects these classes to control spacing and visibility)
🛡️ Proposed fix
-      <Row>
+      <Row
+        className={`event-form-print-note ${
+          (values.additional_information ?? '').trim()
+            ? ''
+            : 'event-form-print-note--empty'
+        }`}
+      >
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/form/EventForm.tsx` at line 283, Restore the missing
"event-form-print-note" className on the Row in the EventForm component and
guard the trim call so it never crashes when additional_information is
undefined: add back className="event-form-print-note" (and preserve logic for
the modifier class "event-form-print-note--empty") and change uses of
values.additional_information.trim() to a safe expression such as
(values.additional_information || "").trim() or check for undefined before
calling trim; update the element rendering logic in EventForm to compute
emptiness via that safe expression so tests and print.scss expectations are
satisfied.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/components/form/EventForm.tsx`:
- Line 283: Restore the missing "event-form-print-note" className on the Row in
the EventForm component and guard the trim call so it never crashes when
additional_information is undefined: add back className="event-form-print-note"
(and preserve logic for the modifier class "event-form-print-note--empty") and
change uses of values.additional_information.trim() to a safe expression such as
(values.additional_information || "").trim() or check for undefined before
calling trim; update the element rendering logic in EventForm to compute
emptiness via that safe expression so tests and print.scss expectations are
satisfied.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c4b50fc0-6080-4d5e-9b30-df0e22afd3ea

📥 Commits

Reviewing files that changed from the base of the PR and between 42ac8b1 and e954dcd.

📒 Files selected for processing (1)
  • src/components/form/EventForm.tsx

@azure-pipelines

Copy link
Copy Markdown

PUISTOTALKOOT-UI branch is deployed to platta: https://puistotalkoot-pr316-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://puistotalkoot-pr316-ui.dev.hel.ninja 😆🎉🎉🎉

@sonarqubecloud

Copy link
Copy Markdown

@azure-pipelines

Copy link
Copy Markdown

PUISTOTALKOOT-UI branch is deployed to platta: https://puistotalkoot-pr316-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://puistotalkoot-pr316-ui.dev.hel.ninja 😆🎉🎉🎉

@ToivoMattilaHelsinki ToivoMattilaHelsinki merged commit 53227af into main Jun 12, 2026
29 checks passed
@ToivoMattilaHelsinki ToivoMattilaHelsinki deleted the PS-275-printable-event-form branch June 12, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants